package JavaSE.demoSE789;


class Student{

    public int data1=10;
    private int data2=20;
    public static int data3=30;

    public Student(){

    }

    /**
     * 静态内部类
     */
    static class InnerClass{

        public int data4 =40;
        public int data5=50;
        public static final int data6=60;

        //Student student = new Student();
        Student student;  //null
        InnerClass(){
            System.out.println("InnerClass()");
        }
        InnerClass(Student student){
            this.student = student;
            System.out.println("InnerClass()");
        }
        public void method(){

            //data1 与data2 不能访问  必须实例化外部类访问
            System.out.println(student.data1);
            System.out.println(student.data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);

            System.out.println("InnerClass中的method方法!");
        }
    }
}
class Test{
    public int a = 9;


    public void test() {
        System.out.println("test!");
    }
}
public class TestDemo2 {

    public static void main(String[] args) {
        /**
         * 匿名内部类
         */
        new TestOne(){

            public void test1(){
                System.out.println("hei");
            }


            public void test() {
                System.out.println("阿这");
            }
        }.test();
    }

    public static void main1(String[] args) {
        //静态的依赖对象----Student.InnerClass()是一个整体
        Student.InnerClass innerClass = new Student.InnerClass(new Student());
        innerClass.method();//这里调用的是不带参数的--空指针异常  必须在上面加参数new Student()
    }
}
